﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using mjc.sync.rules;

namespace mjc.sync.files.rules
{
    public class DeleteFileAction : SyncAction
    {
        public DeleteFileAction( SyncFilter filter ) : base(filter) {

        }

        public void Execute( String s) {
            if (s == null || String.Empty.Equals(s.Trim())) return;

            if( Filter != null && Filter.Matches(s) && File.Exists(s) ) {
                File.Delete(s);                
            }
        }

        public void Execute(FileInfo f)
        {
            if (f == null) return;

            if (Filter != null && Filter.Matches(f.FullName) )
            {
                File.Delete(f.FullName);
            }
        }
    }
}
